(function (window, $, undefined) {
  'use strict';
  //声明全局变量，来储存数据
  var dictData = {
    supplierId: {},
    cityId: {},
    autoBrandId: {},
    autoModelId: {},
    status: {},
    vehicleColor: {},
    fixState: {},
    commercialType: {},
    type: {},
    vehicleType: {},
    checkState: {},
    plateColor: {},
    state: {
      '0': '启用',
      '1': '停用'
    },
    vehiclePurpose: {
      '1': '舒适型',
      '2': '商务7座',
      '3': '豪华轿车'
    },
    fareType: {},
    gender: {}
  };

  var vehicleData = {};
  var driverData = {};
  var curVehicleId = '';

  main(function () {

    // 车辆信息表格 ，
    var $tableVehicle = $('#table-vehicle');
    util.jqGrid($tableVehicle, {
      url: ajaxURL.ORGANIZATION + '/auto/getAutoList',
      // datatype: 'json',
      autowidth: true,
      height: $(window).height() - 370,
      multiselect: true,
      multiboxonly: true,
      // shrinkToFit: false,
      colModel: [
        { label: 'kid', key: true, name: 'kid', width: 30 },
        {
          label: '城市', name: 'cityId', width: 80, formatter: function (v, o, r) {
            return dictData.cityId[v] || '';
          }
        },
        {
          label: '供应商', name: 'supplierId', width: 160, formatter: function (v, o, r) {

            return dictData.supplierId[v] || '';
          }
        },
        {
          label: '车牌号', name: 'autoNo', width: 120, formatter: function (v, o, r) {
            return '<a href="javascript:;" class="view" data-id="' + r.kid + '">' + v + '</a>';
          }
        },
        {
          label: '品牌名称', name: 'autoBrandId', width: 120, formatter: function (v, o, r) {
            return dictData.autoBrandId[v] || '';
          }
        },
        {
          label: '颜色', name: 'vehicleColor', width: 80, formatter: function (v, o, r) {
            return dictData.vehicleColor[v] || '';
          }
        },
        {
          label: '车辆类型', name: 'type', width: 120, formatter: function (v, o, r) {
            return dictData.vehicleType[v] || '';
          }
        },
        {
          label: '录入时间', name: 'createTime', width: 110, formatter: function (v, o, r) {
            return util.getDate(v);
          }
        },
        // { label: '年检时段', name: '', width: 150 },
        {
          label: '服务状态', name: 'state', width: 120, formatter: function (v, o, r) {
            return dictData.state[v] || '';
          }
        },
        { label: '座位数', name: 'seats', width: 80 }
      ],
      loadComplete: function (res) {
        vehicleData = {};
        if (res && res.data) {
          $.each(res.data, function (_, item) {
            vehicleData[item.kid] = item;
          });
        }
      },
      pager: '#pager-vehicle'
    });

    // 司机信息表格（未绑定）
    var $tableDriver = $('#table-driver');
    util.jqGrid($tableDriver, {
      url: ajaxURL.ORGANIZATION + '/driver/getDriverList?isBind=0',
      datatype: 'json',
      width: 920,
      height: 250,
      multiselect: true,
      multiboxonly: true,
      // shrinkToFit: false,
      colModel: [
        { name: 'kid', key: true, hidden: true },
        { label: '编号', name: 'kid', width: 50 },
        {
          label: '城市', name: 'cityId', width: 80, formatter: function (v, o, r) {
            return dictData.cityId[v] || '';
          }
        },
        { label: '所属人力公司', name: 'contractCompany', width: 180 },
        {
          label: '姓名', name: 'name', width: 80
        },
        {
          label: '性别', name: 'gender', width: 80, formatter: function (v, o, r) {
            return dictData.gender[v] || '';
          }
        },
        {
          label: '年龄', name: 'age', width: 80, formatter: function (v, o, r) {
            // 根据身份证号码推算年龄
            var id = r.idCardNumber + '';
            var age = '';
            var birthYear = (id + '').substr(6, 4);
            var curYear = new Date().getFullYear();
            if (birthYear) {
              age = curYear - birthYear;
            }
            return age;
          }
        },
        { label: '身份证', name: 'idCardNumber', width: 180 },
        { label: '电话号码', name: 'phone', width: 120 },
        {
          label: '录入时间', name: 'createTime', width: 100, formatter: function (v, o, r) {
            return util.getDate(v);
          }
        }
      ],
      //储存所有的数据
      loadComplete: function (res) {
        driverData = {};
        if (res && res.data) {
          $.each(res.data, function (_, item) {
            driverData[item.kid] = item;
          });
        }
      },
      //表格的页脚
      pager: '#pager-driver'
    });

    util.selectHtml('[name="vehiclePurpose"]', dictData.vehiclePurpose, '', '', '请选择');

    var dictList = [
      'status',
      // 'state',
      'vehicleColor',
      'fixState',
      'commercialType',
      'vehicleType',
      'checkState',
      'plateColor',
      'gender'
    ];
    var dictName = [
      'status',
      // 'state',
      'vehicleColor',
      'fixState',
      'commercialType',
      'type',
      'checkState',
      'plateColor',
      'gender'
    ];

    util.promiseAll([
      {
        // 获取城市列表
        url: ajaxURL.ORGANIZATION + '/city/getCityList?pageNum=1&pageSize=99999',
        callback: function (res) {
          util.selectHtml($('[name="cityId"]'), res.data, 'cityId', 'name', '请选择');
          $.each(res.data, function (_, item) {
            dictData.cityId[item.cityId] = item.name;
          });
        }
      }, {
        // 获取供应商列表
        url: ajaxURL.ORGANIZATION + '/supplier/getSupplierList?pageNum=1&pageSize=99999',
        callback: function (res) {
          util.selectHtml($('[name="supplierId"]'), res.data, 'kid', 'name', '请选择');
          $.each(res.data, function (_, item) {
            dictData.supplierId[item.kid] = item.name;
          });
        }
      }, {
        // 获取车辆品牌列表
        url: ajaxURL.ORGANIZATION + '/auto/getAutoBrandList?pageNum=1&pageSize=99999',
        callback: function (res) {
          util.selectHtml($('[name="autoBrandId"]'), res.data, 'kid', 'name', '请选择');
          $.each(res.data, function (_, item) {
            dictData.autoBrandId[item.kid] = item.name;
          });
        }
      }, {
        // 获取车辆品牌列表
        url: ajaxURL.ORGANIZATION + '/auto/getAutoModelList?pageNum=1&pageSize=99999',
        callback: function (res) {
          util.selectHtml($('[name="autoModelId"]'), res.data, 'kid', 'name', '请选择');
          $.each(res.data, function (_, item) {
            dictData.autoModelId[item.kid] = item;
          });
        }
      }
    ]).then(function () {
      // 字典表数据获取
      util.getDicts(dictList).then(function (datas) {
        $.each(datas, function (_, data) {
          util.selectHtml('[name="' + dictName[_] + '"]', data, 'value', 'name', '请选择');
          $.each(data, function (x, item) {
            dictData[dictList[_]][item.value] = item.name;
          });
        });

        searchTable();
        $('#btn-search').click(searchTable);
      });
    });

    // 搜索主表
    function searchTable() {
      var data = util.formData('#form-search');
      data.createDate = data.createDate ? util.getTime(data.createDate) : '';
      data.nextFixDate = data.nextFixDate ? util.getTime(data.nextFixDate) : '';
      util.searchGrid($tableVehicle, data);
    }

    // 加载车辆型号列表
    function loadAutoModel() {
      var modelData = {};
      $.each(dictData.autoModelId, function (_, item) {
        modelData[item.kid] = item.name;
      });
      //把数据渲染到页面
      util.selectHtml($('[name="autoModelId"]'), modelData, 'item.kid', 'item.name', '请选择');
    }

    var $searchDriverCondition = $('#form-driverSearch');

    $('#btn-driverSearch').click(function () {
      var data = util.formData($searchDriverCondition);
      util.searchGrid($tableDriver, data);
    });

    var $layerVehicle = $('#layer-vehicle-detail');
    var $formVehicle = $('#form-vehicle-detail');

    // 录入时间
    laydate.render({ elem: '#enterDate' });

    // 年检到期日
    laydate.render({ elem: '#annualInspectionExpireDate' });

    // 车辆注册日期
    laydate.render({ elem: '#carRegDate' });

    // 初次登记表日期
    laydate.render({ elem: '#firstRegFormDate' });

    // 下次年检时间
    laydate.render({ elem: '#nxtAnnualInspection' });

    // 报备日期
    laydate.render({ elem: '#reportDate' });

    // 卫星安装日期
    laydate.render({ elem: '#SATSettingDate' });

    // 保险生效日期
    laydate.render({ elem: '#insurenceStartDate' });

    // 保险到期日期
    laydate.render({ elem: '#insurenceExpireDate' });


    // 运输证有效时间段
    laydate.render({
      range: '至',
      elem: '#transLicePeriod-time',
      done: function (value, date, endDate) {
        var temp = value.split('至');
        $('#transLicePeriod-time').next().val($.trim(temp[0])).next().val($.trim(temp[1]));
      }
    });

    // 车辆类型/车辆品牌联动
    $('#vehicleBrand').change(function () {
      var brandId = $('#vehicleBrand').val()
      var modelData = {};
      $.each(dictData.autoModelId, function (_, item) {
        if (Number(brandId) === item.autoBrandId) {
          modelData[item.kid] = item.name;
        }
        util.selectHtml($('[name="autoModelId"]'), modelData, 'kid', 'name', '请选择');
      });
      $formVehicle.find('#vehicleModel').removeAttr('disabled');
    });

    // 运价类型联动
    $('#cityId, #vehiclePurpose').change(checkFareType)
    function checkFareType() {
      if (!$('#cityId').val() == '' && !$('#vehiclePurpose').val() == '') {
        util.ajax(ajaxURL.PRICE + '/caculationrule/get?cityId=' + $('#cityId').val() + '&carType=' + $('#vehiclePurpose').val(), '', 'GET', util.resCallback(function (res) {
          if (res.data && res.data.kid) {
            $('#fareType').val(res.data.kid)
          } else {
            $('#fareType').val('')
            util.tip.warn('该城市该车辆类型暂无运价类型编码，请核对后再进行操作！')
          }
        }))
      }
    }

    // 车辆图片的上传操作
    util.upload('#photoImg-upload', function (res) {
      util.tip.success('图片上传成功');
      $('#photoImg-preview').attr('src', util.pic(res.data));
      $('#photoImg').val(res.data);
    });

    $('#photoImg-preview').click(function () {
      var id = $('#photoImg').val();
      if (id) {
        $('#layer-view-img').find('img').attr('src', util.pic(id));
        util.layerOpen({
          title: '查看车辆图片',
          content: $('#layer-view-pic')
        });
      }
    });

    $('#photoImg-del').click(function () {
      var id = $('#photoImg').val();
      if (id) {
        //弹出框的确定按钮，这里只是一个提示的弹出框
        layer.confirm('车辆图片为必填值，确认进行清除操作？', function (index) {
          $('#photoImg-preview').attr('src', '/images/1x1.png');
          $('#photoImg').val('');
          layer.close(index);
        });
      }
    });

    // 新增操作
    $('#btn-add').click(function () {
      $layerVehicle.find(':input').removeAttr('disabled');
      $formVehicle.find('#vehicleModel').attr('disabled', 'disabled');
      util.resetForm($formVehicle);
      $formVehicle.find('#vehicle-driverInfo').css("display", "none");
      util.layerOpen({
        title: false,
        // title: '车辆管理 - 新增',
        content: $layerVehicle,
        area: ['1000px', '600px'],
        btn: ['确定新增', '取消'],
        yes: function () {
          vehicleSave()
        },
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
              loadAutoModel();
            }
          });
          return false;
        }
      });
    });

    // 查看车辆
    $tableVehicle.on('click', '.view', function () {
      var $this = $(this);
      var id = $this.data('id');
      $formVehicle.find(':input').removeAttr('placeholder').attr('disabled', 'disabled');
      $formVehicle.find('#vehicle-driverInfo').css("display", "block");

      var data = vehicleData[id];

      // 时间处理
      data.certifyDateA = util.getDate(data.certifyDateA);
      data.certifyDateB = util.getDate(data.certifyDateB);
      data.nextFixDate = util.getDate(data.nextFixDate);
      data.registerDate = util.getDate(data.registerDate);
      data.gpsInstallDate = util.getDate(data.gpsInstallDate);
      data.insurEff = util.getDate(data.insurEff);
      data.insurExp = util.getDate(data.insurExp);
      data.transLicePeriod = util.getDate(data.transDateStart) + ' 至 ' + util.getDate(data.transDateStop);


      util.fillForm($formVehicle, data);

      $('#photoImg-preview').attr('src', data.photoImg ? util.pic(data.photoImg) : '/images/images/1x1.png');
      loadBindDriver(id);
      util.layerOpen({
        // title: '平台车辆管理 - 详情',
        title: false,
        content: $layerVehicle,
        area: ['1000px', '600px'],
      });
      // $('#btn-unbind').css("display", "none");
    });

    // 修改车辆
    $('#btn-edit').click(util.oneCheck($tableVehicle, function (id) {

      var data = vehicleData[id];

      $formVehicle.find(':input').removeAttr('placeholder').removeAttr('disabled', 'disabled');
      $formVehicle.find('#vehicleModel').attr('disabled', 'disabled');
      $formVehicle.find('#vehicle-driverInfo').css("display", "none");
      //清空数据
      util.resetForm($formVehicle);

      data.certifyDateA = util.getDate(data.certifyDateA);
      data.certifyDateB = util.getDate(data.certifyDateB);
      data.nextFixDate = util.getDate(data.nextFixDate);
      data.registerDate = util.getDate(data.registerDate);
      data.gpsInstallDate = util.getDate(data.gpsInstallDate);
      data.insurEff = util.getDate(data.insurEff);
      data.insurExp = util.getDate(data.insurExp);
      data.transLicePeriod = util.getDate(data.transDateStart) + ' 至 ' + util.getDate(data.transDateStop);
      //填充数据
      util.fillForm($formVehicle, data);

      $('#photoImg-preview').attr('src', data.photoImg ? util.pic(data.photoImg) : '/images/images/1x1.png');

      util.layerOpen({
        // title: '平台车辆管理 - 修改',
        title: false,
        content: $layerVehicle,
        area: ['1000px', '600px'],
        btn: ['确认修改', '取消'],
        yes: function() {
          vehicleSave()
        },
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
              loadAutoModel();
            }
          });
          return false;
        }
      });
    }));

    var $formBind = $('#bind-form');

    // 绑定/解绑信息页面
    $('#btn-bind_unbind').click(util.oneCheck($tableVehicle, function (id) {
      curVehicleId = id;
      loadBindDriver(id);
      util.layerOpen({
        // title: '绑定/解绑司机',
        title: false,
        content: $('#layer-vehicle-bind_unbind'),
        area: ['1000px', ''],
      });
    }));

    var driverNum = '';

    // 通过车辆ID获取绑定司机信息
    function loadBindDriver(id) {
      util.resetForm($formBind);
      util.ajax(ajaxURL.ORGANIZATION + '/driver/getDriverList?autoId=' + id, '', 'GET', util.resCallback(function (res) {

        driverNum = res.data.length;

        // if (res.data.length >= 2) {
        //   $('#btn-bind').addClass("hide");
        // } else {
        //   $('#btn-bind').removeClass("hide");
        // }

        loadDriversInfo(driverNum, res.data, 'bind-form');
        loadDriversInfoView(driverNum, res.data, 'bind-form-view');
      }
      ));
    }

    // 加载已绑定司机信息（修改）
    function loadDriversInfo(driverNum, data, driversInfo) {
      var ret = '';

      if (driverNum > 0) {
        for (var i = 0; i < driverNum; i++) {
          ret += '<div class="row form-row form-row-sm marginT10"><div class="col-xs-4"><div class="form-text">司机ID ' + (i + 1) + '：</div><div class="form-container"><input class="form-control kid" name="kid ' + (i + 1) + '" value="' + data[i].kid + '" disabled></div></div><div class="col-xs-4"><div class="form-text">司机姓名 ' + (i + 1) + '：</div><div class="form-container"><input class="form-control" name="name ' + (i + 1) + '"  value="' + data[i].name + '" disabled></div></div><div class="col-xs-4"><div class="form-container"><button class="btn btn-default" type="button" id="btn-unbind" value="' + data[i].kid + '">解绑</button></div></div></div>'
        }
      }
      else {
        ret += '<div class="padding20"><div class="row form-row form-row-sm"><div class="col-xs-12"><span class="text">暂无绑定司机</span></div></div></div>'
      }
      $('#' + driversInfo).html(ret);
    }

    // 页面填充已绑定司机信息（查看）
    function loadDriversInfoView(driverNum, data, driversInfo) {
      var ret = '';

      if (driverNum > 0) {
        for (var i = 0; i < driverNum; i++) {
          ret += '<div class="row form-row form-row-sm marginT10"><div class="col-xs-4"><div class="form-text">司机ID ' + (i + 1) + '：</div><div class="form-container"><input class="form-control kid" name="kid ' + (i + 1) + '" value="' + data[i].kid + '" disabled></div></div><div class="col-xs-4"><div class="form-text">司机姓名 ' + (i + 1) + '：</div><div class="form-container"><input class="form-control" name="name ' + (i + 1) + '"  value="' + data[i].name + '" disabled></div></div></div>'
        }
      }
      else {
        ret += '<div class="padding20"><div class="row form-row form-row-sm"><div class="col-xs-12"><span class="text">暂无绑定司机</span></div></div></div>'
      }
      $('#' + driversInfo).html(ret);
    }

    // 绑定操作
    $('#btn-bind').click(util.oneCheck($tableDriver, function (id) {

      var url = ajaxURL.ORGANIZATION + '/auto/bindDriver?autoId=' + curVehicleId + '&driverId=' + id + '';

      util.ajax(url, '', 'POST', util.resCallback(function (res) {
        util.tip.success('操作成功');
        loadBindDriver(curVehicleId);
        $tableDriver.trigger('reloadGrid');
      }));
    }));

    // 解绑操作
    $('#bind-form').on('click', '#btn-unbind', function () {

      var $this = $(this);
      var drivId = $this.val();
      var url = ajaxURL.ORGANIZATION + '/auto/unBindDriver?autoId=' + curVehicleId + '&driverId=' + drivId + '';

      util.ajax(url, '', 'POST', util.resCallback(function (res) {
        util.tip.success('操作成功');
        loadBindDriver(curVehicleId);
        $tableDriver.trigger('reloadGrid');
      }));
    });

    // 删除车辆
    $('#btn-del').click(util.oneCheck($tableVehicle, function (id) {
      layer.confirm('删除该车辆后，该车下绑定的司机信息将会失效，确定删除该车辆信息？', {
        btn: ['确定', '再想一想']
      }, function () {
        util.ajax(ajaxURL.ORGANIZATION + '/auto/removeAuto?kid=' + id, '', 'POST', util.resCallback(function (res) {
          util.tip.success('删除成功');
          $tableDriver.trigger('reloadGrid');
        }));
      });
    }));

    // 导出
    $('#btn-export').click(function () {
      util.tip.warn('导出操作...');
    });

    // 导入
    $('#btn-import').click(function () {
      util.tip.warn('导出操作...');
    });

    //表格验证
    var $validate = $formVehicle.validate({
      rules: {
        source: { required: true },
        cityId: { required: true },
        supplierId: { required: true },
        type: { required: true },
        autoBrandId: { required: true },
        autoModelId: { required: true },
        vehicleColor: { required: true },
        autoNo: { required: true, maxlength: 32 },
        plateColor: { required: true },
        seats: { required: true, digits: true, maxlength: 10 },
        vehiclePurpose: { required: true },
        photoImg: { required: true },
        ownerName: { required: true, stringCheck: true, maxlength: 64 },
        engineId: { required: true, maxlength: 32 },
        vin: { required: true, maxlength: 17, minlength: 17 },
        certifyDateA: { required: true },
        fuelType: { required: true, maxlength: 32 },
        engineDisplace: { required: true, maxlength: 32 },
        certificate: { required: true, maxlength: 64 },
        transAgency: { required: true, maxlength: 256 },
        transArea: { required: true, maxlength: 256 },
        transDateStart: { required: true },
        transDateStop: { required: true },
        certifyDateB: { required: true },
        fixState: { required: true },
        nextFixDate: { required: true },
        checkState: { required: true },
        registerDate: { required: true },
        commercialType: { required: true },
        fareType: { required: true },
        gpsImei: { required: true, maxlength: 128 },
        gpsBrand: { required: true, maxlength: 256 },
        gpsModel: { required: true, maxlength: 64 },
        gpsInstallDate: { required: true },
        state: { required: true },
        totalMileage: { required: true, number: true, maxlength: 64 },
        feePrintId: { required: true, maxlength: 32 },
        insurCom: { required: true, maxlength: 64 },
        insurNum: { required: true, number: true, maxlength: 64 },
        insurType: { required: true },
        insurCount: { required: true, number: true, maxlength: 10 },
        insurEff: { required: true },
        insurExp: { required: true },
        remark: { required: true, maxlength: 200 },
        transLicePeriod: { required: true }
      },
      messages: {
        source: { required: '请选择车辆来源' },
        cityId: { required: '请选择城市' },
        supplierId: { required: '请选择供应商' },
        type: { required: '请选择车辆类型' },
        autoBrandId: { required: '请选择车辆品牌' },
        autoModelId: { required: '请选择车辆型号' },
        vehicleColor: { required: '请选择车辆颜色' },
        autoNo: { required: '请填写车牌号' },
        plateColor: { required: '请选择车牌号颜色' },
        seats: { required: '请填写车辆座位数', digits: '请输入实数' },
        vehiclePurpose: { required: '请选择用车类型' },
        photoImg: { required: '请上传车辆照片' },
        ownerName: { required: '请填写车辆所有人' },
        engineId: { required: '请填写发动机号' },
        vin: { required: '请填写车辆vin码' },
        certifyDateA: { required: '请选择车辆注册日期' },
        fuelType: { required: '请填写燃料类型' },
        engineDisplace: { required: '请填写车辆排量' },
        certificate: { required: '请填写运输证字号' },
        transAgency: { required: '请填写发证机构' },
        transArea: { required: '请填写经营区域' },
        transDateStart: { required: '请选择运输证有效期' },
        transDateStop: { required: '请选择运输证有效期' },
        certifyDateB: { required: '请选择初次登记表日期' },

        fixState: { required: '请选择车辆检修状态' },
        nextFixDate: { required: '请选择下次年检时间' },
        checkState: { required: '请选择年度审核状态' },
        registerDate: { required: '请选择报备时间' },
        commercialType: { required: '请选择服务类型' },
        fareType: { required: '请通过城市及用车类型绑定运价类型' },
        gpsImei: { required: '请输入卫星MEI号' },
        gpsBrand: { required: '请输入卫星品牌' },
        gpsModel: { required: '请输入卫星型号' },
        gpsInstallDate: { required: '请选择卫星安装日期' },
        state: { required: '请选择车辆状态' },
        totalMileage: { required: '请输入行驶总里程数' },
        feePrintId: { required: '请输入打印身背序列号' },

        insurCom: { required: '请输入保险公司名称' },
        insurNum: { required: '请输入保险号' },
        insurType: { required: '请输入保险类型' },
        insurCount: { required: '请输入保险金额' },
        insurEff: { required: '请选择保险生效日期' },
        insurExp: { required: '请输入保险到期日期' },
        remark: { required: '请填写备注' },
        transLicePeriod: { required: '请选择运输证有效期' }
      },
      //这里是一个方法，当表单验证报错的时候就会触发，
      errorPlacement: function (error, element) { //错误信息位置设置方法
        error.appendTo(element.parents('.form-container')); //这里的element是录入数据的对象
      }
    });

    // $('#vehicle-save').click(function () {
    function vehicleSave() {

      //获取到所有的表单数据
      var data = util.formData($formVehicle);

      //转成时间戳
      util.toTimeStamp(data, [
        'certifyDateA',
        'certifyDateB',
        'nextFixDate',
        'registerDate',
        'gpsInstallDate',
        'insurEff',
        'insurExp',
        'transDateStart',
        'transDateStop'
      ]);
      //判断图片存在与否
      if (!data.photoImg) {
        return util.tip.warn('请先上传车辆图片');
      }

      if ($validate.form()) {
        // data.kid 来决定是什么操作，有为修改，无为新增
        var url = ajaxURL.ORGANIZATION + (data.kid ? '/auto/updateAuto' : '/auto/addAuto');
        util.ajax(url, JSON.stringify(data), 'POST', util.resCallback(function (res) {
          //隐藏所有窗口
          layer.closeAll();
          //提示信息
          util.tip.success('操作成功');

          loadAutoModel();
          //重新加载页面
          $tableVehicle.trigger('reloadGrid');
        }));
      }
    }
    // });

  });
})(window, jQuery);
